
Ext.define('DCApp.view.pay.List', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.paylist',
    
    requires: [
        'DCApp.view.pay.ListModel',
        'DCApp.controller.ListController'
    ],

    // Connects to our View Controller (Ticket.view.ticket.SearchController) and View Model
    // (Ticket.view.ticket.SearchModel).
    controller: 'list',
    plugins: ['gfilters'],
    viewModel: {
        type: 'paylist'
    },
    header:false,
    selType: 'cellmodel',
    bind: {
        store: '{objs}'
    },
    
    tbar: ['->',{
        text: '录入',
        handler: 'onNew'
    }],
    
	
	listeners: {
        itemdblclick: 'onDblClick'
    },
    
    columns: [
            {
                text     : '编号',
                dataIndex: 'id'
            },
            {
                text     : '题名',
                dataIndex: 'name',
                filter: {
                    type: 'string',
                    itemDefaults: {
                        emptyText: 'Search for...'
                    }
                }
            },
            {
                text     : '当事人',
                dataIndex: 'authorId',
                width:200
            },
            {
                text     : '类别',
                dataIndex: 'class_',
	            summaryType: 'count',
	            summaryRenderer: function(value, summaryData, dataIndex) {
	                return  '（ '+value + ' 项）';
	            }
            },
            {
                text     : '字数',
                dataIndex: 'docNumber',
	            summaryType: 'sum',
	            renderer: function(value, metaData, record, rowIdx, colIdx, store, view){
	                return value + ' 字';
	            },
	            summaryRenderer: function(value, summaryData, dataIndex) {
	                return value + ' 字';
	            },
	            field: {
	                xtype: 'numberfield'
	            }
	         },
            {
                text     : '稿酬',
				formatter: 'usMoney',
				dataIndex: 'reward',
                editor: {
                    xtype: 'numberfield',
                    allowBlank: false,
                    minValue: 0,
                    maxValue: 100000
                },
                summaryType: function(records, values) {
                var i = 0,
                    length = records.length,
                    total = 0,
                    record;

                for (; i < length; ++i) {
                    record = records[i];
                    total += record.get('reward');
                }
                return total;
            },
            summaryRenderer: Ext.util.Format.usMoney

            },
            {
                text     : '确认',
                xtype: 'checkcolumn',
                dataIndex: 'rewardFlag'
            }
            
        ],
    initComponent: function(){
    	this.callParent();
    }
 });
